package com.test.group6.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.test.group6.domain.EnterpriseInformation;

@Mapper
public interface AddEnterpriseMapper {
	@Insert("insert into enterprise_information("
			+ "enterprise_id,enterprise_name,card_type,"
			+ "card_id,enterprise_date,capital,"
			+ "address,workes,register_date"
			+ ") values("
			+ "#{enterpriseInformation.enterpriseId},"
			+ "#{enterpriseInformation.enterpriseName},"
			+ "#{enterpriseInformation.cardType},"
			+ "#{enterpriseInformation.cardId},"
			+ "#{enterpriseInformation.enterpriseDate},"
			+ "#{enterpriseInformation.capital},"
			+ "#{enterpriseInformation.address},"
			+ "#{enterpriseInformation.workes},"
			+ "#{enterpriseInformation.registerDate}"
			+ ")")
    int addNewEnterprise(@Param("enterpriseInformation")EnterpriseInformation enterpriseInformation);
	
	@Select("select enterprise_id from enterprise_information order by enterprise_id desc limit 0,1")
    String getMaxIdInEnterprise();
	@Select("<script>"+"select count(enterprise_id) from enterprise_information "+"<where> "
			+ "<if test='enterpriseName!=null'>enterprise_name=#{enterpriseName}</if>"
			+ "<if test='cardType!=null'>and card_type=#{cardType}</if> "
			+ "<if test='cardId!=null'>and card_id=#{cardId}</if> "+"</where>"+"</script>")
	int getRepeatEnterpriseCount(String enterpriseName,String cardType,String cardId);
}
